package com.ss.android.article.base.feature.detail.presenter;

import android.content.Intent;
import android.view.View;
import com.ss.android.article.base.feature.detail2.cc;
import com.ss.android.article.base.feature.detail2.video.a.e;
import com.ss.android.article.base.feature.detail2.view.NewDetailActivity;
import com.ss.android.article.base.feature.detail2.view.NewVideoDetailActivity;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.newmedia.a.AdsAppBaseActivity;
import com.ss.android.newmedia.util.AppUtil;

import org.json.JSONException;
import org.json.JSONObject;

final class x implements View.OnClickListener {
    private final w a;

    x(w arg1) {
        this.a = arg1;
    }

    public final void onClick(View arg18) {
        JSONObject v2_3;
        int v16;
        long v14;
        long v12;
        Object v10;
        w v11 = this.a;
        if(arg18 == null) {
            return;
        }

        Object v3 = null;
        try {
            Object v2_1 = arg18.getTag();
            if((v2_1 instanceof w)) {
                v10 = v2_1;
            }
            else {
                v10 = v3;
            }
            long v2_2 = System.currentTimeMillis();
            if(v10 == null) {
                return;
            }

            if(((w)v10).r == null) {
                return;
            }

            if(((w)v10).r.groupId <= 0) {
                return;
            }

            if(v2_2 - ((w)v10).r.clickTimestamp < 1000) {
                return;
            }

            v12 = ((w)v10).r.groupId;
            v14 = ((w)v10).r.itemId;
            v16 = ((w)v10).r.aggrType;
            if(v11.x != 2) {
                ((w)v10).r.clickTimestamp = v2_2;
                ((w)v10).mTitleView.setSelected(false);
                if(((w)v10).r.clickTimestamp > 0) {
                    ((w)v10).mTitleView.setTextColor(v11.u.getColorStateList(com.ss.android.article.browser.R.color.c1));
                }
            }

            v2_3 = new JSONObject();
            if(v11.x != 2) {
                if(v11.w <= 0) {
                }else {
                    try {
                        v2_3.put("from_gid", v11.w);
                    } catch (JSONException v2_4) {
                    }
                }
                String v2_5 = ((w)v10).r.outerSchema;
                if(!android.support.design.a.isTextEmpty(v2_5) && (AppUtil.b(v11.s, "com.youku.phone", v2_5))) {
                    AppUtil.b(v11.s, v2_5);
                    MobClickCombiner.onEvent(v11.s, "detail", "enter_youku");
                    return;
                }
                MobClickCombiner.onEvent(v11.s, "detail", "click_related_gallery", v11.w, 0);

            }else {
                try {
                    v2_3.put("item_id", v14);
                } catch (JSONException v2_4) {
                }
            }
            if(e.a(arg18, ((w)v10).r, "gallery")) {
                return;
            }

            if(((v11.s instanceof cc)) && (((cc)v11.s).a(v11.r))) {
                return;
            }

            if(!android.support.design.a.isTextEmpty(v11.r.openPageUrl)) {
                AppUtil.b(v11.s, AdsAppBaseActivity.b(((w)v10).r.openPageUrl));
                return;
            }

            if(!android.support.design.a.isTextEmpty(v11.r.openUrl)) {
                AppUtil.b(v11.s, AdsAppBaseActivity.b(((w)v10).r.openUrl));
                return;
            }

            Intent v2_6 = new Intent(v11.s, NewDetailActivity.class);
            v2_6.putExtra("view_single_id", true);
            v2_6.putExtra("group_id", v12);
            v2_6.putExtra("item_id", v14);
            v2_6.putExtra("aggr_type", v16);
            v2_6.putExtra("detail_source", "click_related");
            v2_6.putExtra("group_flags", ((w)v10).r.groupFlags);
            if(android.support.design.a.b(((long)((w)v10).r.groupFlags))) {
                v2_6.setClass(v11.s, NewVideoDetailActivity.class);
            }

            if(v11.w > 0) {
                v2_6.putExtra("from_gid", v11.w);
            }

            v11.s.startActivity(v2_6);
        }
        catch(Throwable v2) {
        label_76:
            v2.printStackTrace();
        }
    }
}

